//
//  ZBActivityView.m
//  YouHui
//
//  Created by  on 11-12-2.
//  Copyright (c) 2011年 netease. All rights reserved.
//

#import "ZBActivityView.h"

@implementation ZBActivityView

@dynamic backgroundImage;

-(id)initWithActivityIndicatorStyle:(UIActivityIndicatorViewStyle)style {
    if (self=[super initWithFrame:CGRectMake(0, 0, 30, 31)]) {
        _backgroundImageView =[[UIImageView alloc] initWithFrame:self.bounds];
        [self addSubview:_backgroundImageView];
        _indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:style];
        _indicator.frame = CGRectInset(self.bounds, 5, 5);
        [self addSubview:_indicator];
    }
    return self;
}

-(void)dealloc {
    [_indicator release];  
    [_backgroundImageView release];
    [super dealloc];
}

-(void)setBackgroundImage:(UIImage *)backgroundImage {
    _backgroundImageView.image = backgroundImage;  
}

-(UIImage*)backgroundImage {
    return _backgroundImageView.image;
}

-(void)startAnimating {
    if (_animating) {
        return;
    }
    _animating = YES;
    [_indicator startAnimating];
}
-(void)stopAnimating {
    if (!_animating) {
        return;
    }
    _animating = NO;
    [_indicator stopAnimating];    
}

@end
